<template>
  <view class="product-page">
    <!-- 标签栏 -->
    <view class="tab-bar">
      <view 
        class="tab-item" 
        v-for="(tab, index) in tabs" 
        :key="index"
        :class="{ active: currentTab === index }"
        @click="switchTab(index)"
      >
        <text class="tab-text">{{ tab }}</text>
      </view>
    </view>

    <!-- 商品展示区域 -->
    <view class="product-section">
      <view class="product-grid">
        <view class="product-item" v-for="(product, index) in products" :key="index" @click="goToProduct(product)">
          <image class="product-image" :src="product.image"></image>
          <text class="product-name">{{ product.name }}</text>
          <view class="product-tags">
            <view class="tag self-operated">自营</view>
            <view class="tag flash-sale">秒杀</view>
          </view>
          <view class="promotion-tags">
            <view class="promo-tag">满10减9</view>
            <view class="promo-tag">满10减4</view>
            <view class="promo-tag">满10减5</view>
          </view>
          <view class="price-section">
            <text class="price-symbol">¥</text>
            <text class="price-value">{{ product.price }}</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      currentTab: 0,
      tabs: ['所有品牌', 'YSL1', 'ASd234', '1022', '1234'],
      products: [
        { id: 1, name: 'YSL口红', image: '/static/balance/口红.png', price: '0.01' },
        { id: 2, name: 'MAC口红', image: '/static/balance/口红.png', price: '199.00' },
        { id: 3, name: 'Dior口红', image: '/static/balance/口红.png', price: '399.00' },
        { id: 4, name: 'Chanel口红', image: '/static/balance/口红.png', price: '359.00' },
        { id: 5, name: 'TF口红', image: '/static/balance/口红.png', price: '459.00' },
        { id: 6, name: '纪梵希口红', image: '/static/balance/口红.png', price: '299.00' }
      ]
    }
  },
  methods: {
    switchTab(index) {
      this.currentTab = index;
    },
    goToProduct(product) {
      uni.navigateTo({
        url: `/pages/product/product?id=${product.id}`
      });
    }
  }
}
</script>

<style scoped>
.product-page {
  min-height: 100vh;
  background-color: #f5f5f5;
}

/* 标签栏 */
.tab-bar {
  display: flex;
  background-color: #fff;
  border-bottom: 1rpx solid #eee;
  padding: 0 30rpx;
  overflow-x: auto;
}

.tab-item {
  flex-shrink: 0;
  text-align: center;
  padding: 30rpx 20rpx;
  position: relative;
}

.tab-text {
  font-size: 28rpx;
  color: #666;
  white-space: nowrap;
}

.tab-item.active .tab-text {
  color: #ff3838;
  font-weight: bold;
}

.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60rpx;
  height: 4rpx;
  background-color: #ff3838;
  border-radius: 2rpx;
}

/* 商品展示区域 */
.product-section {
  padding: 20rpx;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20rpx;
}

.product-item {
  background-color: #fff;
  border-radius: 16rpx;
  padding: 20rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  position: relative;
}

.product-image {
  width: 100%;
  height: 200rpx;
  border-radius: 12rpx;
  object-fit: cover;
  margin-bottom: 16rpx;
}

.product-name {
  display: block;
  font-size: 28rpx;
  color: #333;
  margin-bottom: 12rpx;
  line-height: 1.2;
}

.product-tags {
  margin-bottom: 12rpx;
}

.tag {
  display: inline-block;
  padding: 4rpx 12rpx;
  border-radius: 6rpx;
  font-size: 20rpx;
  color: #fff;
  margin-right: 8rpx;
}

.self-operated {
  background-color: #ff3838;
}

.flash-sale {
  background-color: #ff6b35;
}

.promotion-tags {
  display: flex;
  gap: 8rpx;
  margin-bottom: 16rpx;
  flex-wrap: wrap;
}

.promo-tag {
  padding: 4rpx 8rpx;
  background-color: #fff2f0;
  color: #ff3838;
  border: 1rpx solid #ff3838;
  border-radius: 6rpx;
  font-size: 20rpx;
}

.price-section {
  display: flex;
  align-items: baseline;
}

.price-symbol {
  font-size: 32rpx;
  font-weight: bold;
  color: #ff3838;
}

.price-value {
  font-size: 28rpx;
  font-weight: bold;
  color: #ff3838;
  margin-left: 4rpx;
}
</style> 
